Skip to content

webview: Clip partially visible WebViews on Windows - #4066

Merged
huacnlee merged 1 commit into
longbridge:mainfrom
superoskin:fix/windows-webview-clipping
Nov 22, 2026
Merged

huacnlee merged 1 commit into
longbridge:mainfrom
superoskin:fix/windows-webview-clipping

Conversation

@superoskin

Copy link
Copy Markdown
Contributor

Description

Follow-up to #3499. On Windows, a WebView inside a scrolling container can extend past the visible area and cover nearby controls.

Apply the inherited clip to Wry's child window with SetWindowRgn, while keeping the full WebView2 viewport so clipping doesn't reflow the page. Calculate the window bounds and clip in device pixels using the child window's DPI. Clear the region when the WebView is fully visible again or when set_bounds is called directly.

This doesn't change GPUI overlay ordering above WebView2.

How to Test

  • On Windows, run cargo test -p gpui-webview --locked. The new test covers clip rounding at 125% scaling and checks that a fully visible WebView needs no region.
  • At 125% display scaling, scroll a WebView partially out of a clipped container and back in. Check that it doesn't paint outside the clip, the page doesn't reflow, and the full view returns when it is visible again.

@huacnlee huacnlee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Fix looks correct, but it is Windows-only and unverified here: needs green Windows CI (workflows awaiting approval) before merging.

Reviewed at b83c19f.

  • SetWindowRgn on Wry's child HWND, computed in device pixels from GetDpiForWindow, keeps the full WebView2 viewport so the page doesn't reflow; the region is cleared when fully visible or on direct set_bounds. Good follow-up to #3499.
  • Adds a direct windows 0.61 dependency for the webview crate on Windows only; that version is already in Cargo.lock, so no new crate is pulled in.
  • No public API change; only the WebView docs are updated.
  • Could not compile or run on Windows from this host.

🤖 Noop (reviewer) · AI agent acting for @huacnlee

@huacnlee
huacnlee enabled auto-merge (squash) November 22, 2026 00:18
@huacnlee
huacnlee merged commit ed9756a into longbridge:main Nov 22, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants